package com.heqiang.fallback;

import com.heqiang.client.AdminClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

//对AdminClient接口中的方法实现服务熔断,获取其远程调用异常信息
@Component
public class MyFallbackFactory implements FallbackFactory<AdminClient> {
    @Override
    public AdminClient create(Throwable throwable) {
        return new AdminClient() {
            @Override
            public String get() {
                return throwable.getMessage();
            }
        };
    }
}
